
const requireDirectory = require('require-directory')
const Router = require('koa-router')
class InitManager{
    static initCore(app) {

        InitManager.app = app
        InitManager.initRouter()
    }

    static initRouter() {
        var routerUrl = `${process.cwd()}/api`
        requireDirectory(module,routerUrl,{
            visit:moduleRoutes
        })
        
        
        function moduleRoutes(obj){
            if(obj instanceof Router){
                InitManager.app.use(obj.routes())
            }
        }
    }

}

module.exports = InitManager


